package com.qiaoanju.domain;

/**
 * 分页信息model
 * Created by eversec on 2017/10/21.
 */
public class PageModel {

    private int curPage;
    private int pageSize = 10;
    private int totleNum;
    private int totlePage;
    private int areaSize = 5;
    private int areaIndex;

    public PageModel(){}
    public PageModel(int curPage,int pageSize,int totleNum){
        setCurPage(curPage);
        setPageSize(pageSize);
        setTotleNum(totleNum);
    }
    public PageModel(int curPage){
        setCurPage(curPage);
    }

    public PageModel(int curPage,int pageSize){
        this.curPage = curPage;
        setPageSize(pageSize);
    }


    public int getCurPage() {
        return curPage;
    }
    public void setCurPage(int curPage) {
        if(curPage <= 0){
            curPage = 1;
        }
        this.curPage = curPage;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
        initTotlePage(pageSize,this.totleNum);
    }
    public int getTotleNum() {
        return totleNum;
    }
    public void setTotleNum(int totleNum) {
        this.totleNum = totleNum;
        initTotlePage(this.pageSize,totleNum);
    }
    public int getTotlePage() {
        return totlePage;
    }
    public void setTotlePage(int totlePage) {
        if(totlePage <= 0){
            totlePage = 1;
        }
        this.totlePage = totlePage;
    }

    public void initTotlePage(int pageSize, int totleNum){
        setTotlePage(new Double(Math.ceil(totleNum/(double)pageSize)).intValue());
        this.areaIndex = new Double(Math.ceil(this.curPage/(double)areaSize)).intValue();
    }

    public int getAreaSize() {
        return areaSize;
    }
    public void setAreaSize(int areaSize) {
        this.areaSize = areaSize;
        initTotlePage(this.pageSize,this.totleNum);

    }
    public int getAreaIndex() {
        return areaIndex;
    }
    public void setAreaIndex(int areaIndex) {
        this.areaIndex = areaIndex;
    }

}
